package com.springmvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class LoginController {

    /**
     * 跳转到login页面
     * @return
     */
    @RequestMapping("/login")
    public String login(){
        return "login";
    }

    /**
     * 默认get、post都可以接收参数
     * params = "id"-->id必须存在
     * @param userName
     * @param password
     * @return
     */
    //@RequestMapping(value = "/doLogin",method = RequestMethod.GET,params = "id")
    @RequestMapping(value = "/doLogin",method = RequestMethod.GET,params = {"id","userName","password"})
    public String doLogin(String userName,String password){
        if("admin".equals(userName) && "123456".equals(password)){
            return "success";
        }
        return "error";
    }

}
